<?php

namespace app\models;

use think\Model;

class SystemConfigModel extends Model
{
    protected $table = 'edu_system_config';

    /**
     * User: wufeng
     * Date: 2020/03/21.
     *
     * @param $params
     *
     * @throws \think\exception\DbException
     *
     * @return array
     */
    public function getConfigLists($params)
    {
        $page = isset($params['page']) ? (int) $params['page'] : 1;
        $listRows = isset($params['limit']) ? (int) $params['limit'] : 10;
        $where = [];
        $listData = self::where($where)
            ->paginate($listRows, false, ['page' => $page])
            ->toArray();
        if (!empty($listData)) {
            foreach ($listData['data'] as &$item) {
                $item['type_text'] = DictionaryModel::getById($item['type'], 'name');
                if(0 === (int) $item['group']){
					$item['group_text'] = '不分组';
				}else if (1 === (int) $item['group']){
					$item['group_text'] = '系统';
				}
            }
        }

        return $listData;
    }
}
